{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3",
   "language": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "# 变量和标示符"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "## 变量赋值\n",
    "\n",
    "Python 中的变量赋值不需要类型声明\n",
    "\n",
    "如果使用没有赋值过的变量，会报错 `NameError: name 'x' is not defined`\n",
    "\n",
    "Python 是动态类型的语言，可以为变量赋任意类型的值，也可以任意修改变量的值"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 10\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(b)"
   ]
  },
  {
   "source": [
    "## 标示符\n",
    "\n",
    "Python 中所有可以自主命名的内容都属于标示符，比如：变量名、函数名、类名\n",
    "\n",
    "标示符规范：\n",
    "\n",
    "1. 标示符中可以含有字母、数字、 `_` ，但是不能以数字开头\n",
    "2. 标示符不能是 Python 中的关键字和保留字，也不建议使用 Python 中的函数名作为标示符，因为这样会导致函数被覆盖\n",
    "3. 命名规范：\n",
    "    - 下划线命名法 —— 所有字母小写，单词之间使用 `_` 分割\n",
    "    - 大驼峰命名法 —— 首字母大写，每个单词开头字母大写，其余字母小写\n",
    "\n",
    "如果使用不符合标准的标示符，将会报错 `SyntaxError: invalid syntax`"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "MyAge = 18\n",
    "my_age = 18\n",
    "print(MyAge)\n",
    "print(my_age)"
   ]
  }
 ]
}